package jin.chen.common.utils;

/**
 *处理返回结果类
 * 主要是返回给前端
 * status状态
 * msg数据信息
 * data数据
 */
public class Result {

    private Integer status;
    private String msg;
    private Object data;

    public void setStatus(Integer status) {
        this.status = status;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getStatus() {
        return status;
    }

    public String getMsg() {
        return msg;
    }

    public Object getData() {
        return data;
    }

    /**
     * OK表示返回正确，200状态码
     * @return
     */
    public static Result OK(){
        Result result = new Result(200, "ok");
        return result;
    }

    /**
     * OK表示返回正确，200状态码
     * @return
     */
    public static Result OK(Object data){
        Result result = new Result(200, "ok", data);
        return result;
    }

    /**
     * errorMsg返回500加上错误信息
     * @param msg
     * @return
     */
    public static Result errorMsg(String msg){
        Result result = new Result(500, msg);
        return result;
    }

    public Result(Integer status) {
        this.status = status;
    }

    public Result(Integer status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public Result(Integer status, Object data) {
        this.status = status;
        this.data = data;
    }

    public Result(Integer status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }
}
